﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace BeatEmUp.Characters
{
    [Serializable]
    class Stats
    {
        private Random r = new Random();
        private int dmg;
        private int _hp;
        private int score = 0;
        public int hp
        {
            get
            {
                return _hp ;
            }
            set
            {
                if (value > maxHp)
                {
                    _hp = maxHp;
                }
                else
                {
                    _hp = value;
                }
            }
        }
        public int maxHp
        {
            get;
            set;
        }
        public int strenght
        {
            get;
            set;
        }
        public int luck
        {
            get;
            set;
        }
        public int level
        {
            get;
            set;
        }
        public int Score
        {
            get
            {
                return score;
            }
        }
        public void damageGiven(int dmg)
        {
           this.dmg += dmg;
           this.score += dmg;
           Debug.WriteLine("Damage to next level: " + ((Math.Pow(level, 1.5) * 100) - this.dmg).ToString()); 
           if (this.dmg >= Math.Pow(level,1.5)*100)
           {
               LevelUp();
               this.dmg = 0;
           }
        }
        public Stats()
        {
            hp = 100;
            maxHp = 100;
            strenght = 1;
            luck = 1;
        }
        public  void LevelUp()
        {
            ++level;
            strenght += r.Next(1, 5);
            luck += r.Next(1, 5);
            maxHp += r.Next(20,100);
            hp = maxHp;
        }
        public int giveMeAttackPower()
        {
            int pow = (strenght / 2) + r.Next(0, (strenght / 2))+r.Next(0,luck/5);
            return pow;
        }
    }
}
